package com.newtouch.bxzs.enterprise.controller;

import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import com.newtouch.bxzs.enterprise.config.MyLog;
import com.newtouch.bxzs.enterprise.model.bo.EnterpriseCustomerBO;
import com.newtouch.bxzs.enterprise.model.bo.EnterpriseCustomerDetailBO;
import com.newtouch.bxzs.enterprise.model.vo.EnterpriseCustomerDetailVO;
import com.newtouch.bxzs.enterprise.model.vo.EnterpriseCustomerVO;
import com.newtouch.bxzs.enterprise.service.EnterpriseCustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 企业客户管理Controller
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/2/3 9:44</td>
 * <td>dingqianbin</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author dingqianbin
 * @version 1.0.0
 * @since 1.0.0
 */
@Api(tags = "企业客户管理")
@RestController
@RequestMapping(value = "/enterpriseCustomerController")
@SuppressWarnings("unchecked")
public class EnterpriseCustomerController {

    @Autowired
    private EnterpriseCustomerService enterpriseCustomerService;

    /** 静态变量：系统日志 */
    private static final Log logger = LogFactory.getLog(EnterpriseCustomerController.class);

    @ApiOperation(value = "获取企业客户列表信息", notes = "可按企业名称搜索")
    @PostMapping("/getCustomerList")
    @MyLog(systemFunctionName = "企业客户管理", systemFunctionUrl = "/enterpriseCustomerController/getCustomerList", userOperationType = 4, userOperationSummary = "获取企业客户列表信息")
    public BaseResponse<EnterpriseCustomerBO> getCustomerList(@RequestBody EnterpriseCustomerVO enterpriseCustomerVO) {
        logger.info("获取企业客户列表信息,可按客户名称搜索");
        return RespGenerator.returnOK(enterpriseCustomerService.getCustomerList(enterpriseCustomerVO));
    }

    @ApiOperation(value = "获取企业客户详情")
    @PostMapping("/getEnterpriseCustomerDetail")
    @MyLog(systemFunctionName = "企业客户管理", systemFunctionUrl = "/enterpriseCustomerController/getEnterpriseCustomerDetail", userOperationType = 4, userOperationSummary = "获取企业客户详情")
    public BaseResponse<EnterpriseCustomerDetailBO> getEnterpriseCustomerDetail(@RequestBody EnterpriseCustomerVO enterpriseCustomerVO) {
        logger.info("获取企业客户详情");
        return RespGenerator.returnOK(enterpriseCustomerService.getEnterpriseCustomerDetail(enterpriseCustomerVO.getEnterpriseCustomerId()));
    }

    @ApiOperation(value = "增加/修改企业客户信息")
    @PostMapping("/modifyEnterpriseCustomer")
    @MyLog(systemFunctionName = "企业客户管理", systemFunctionUrl = "/enterpriseCustomerController/modifyEnterpriseCustomer", userOperationType = 5, userOperationSummary = "增加/修改企业客户信息")
    public BaseResponse<Integer> modifyEnterpriseCustomer(@RequestBody EnterpriseCustomerDetailVO enterpriseCustomerDetailVO) {
        logger.info("增加/修改企业客户信息");
        return RespGenerator.returnOK(enterpriseCustomerService.modifyEnterpriseCustomer(enterpriseCustomerDetailVO));
    }

    @ApiOperation(value = "删除/批量删除企业客户信息")
    @PostMapping("/deleteEnterpriseCustomer")
    @MyLog(systemFunctionName = "企业客户管理", systemFunctionUrl = "/enterpriseCustomerController/deleteEnterpriseCustomer", userOperationType = 3, userOperationSummary = "删除/批量删除企业客户信息")
    public BaseResponse<Integer> deleteEnterpriseCustomer(@RequestBody List<EnterpriseCustomerDetailVO> enterpriseCustomerDetailVOList) {
        logger.info("删除/批量删除企业客户信息");
        return RespGenerator.returnOK(enterpriseCustomerService.deleteEnterpriseCustomer(enterpriseCustomerDetailVOList));
    }

}
